﻿#ifndef MYINI_H
#define MYINI_H

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>

#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif

#define MAX_FILE_SIZE 1024*16
#define LEFT_BRACE '['
#define RIGHT_BRACE ']'

class CIni
{
public:
    // 构造函数
    CIni();
    // 析够函数
    virtual ~CIni();

public:
    int read_profile_string( const char *section, const char *key,char *value, int size,const char *default_value, const char *file);
    int read_profile_int( const char *section, const char *key,int default_value, const char *file);
    int write_profile_string( const char *section, const char *key,const char *value, const char *file);
    int load_ini_file(const char *file, char *buf,int *file_size);

private:
    int newline(char c);
    int end_of_string(char c);
    int left_barce(char c);
    int isright_brace(char c );
    int parse_file(const char *section, const char *key, const char *buf,int *sec_s,int *sec_e,
                          int *key_s,int *key_e, int *value_s, int *value_e);

};
#endif // MYINI_H
